/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dp1.titandevelop.titano.view.admin;

import dp1.titandevelop.titano.view.prod.ModulosT_PRO_Productos;
import dp1.titandevelop.titano.persistent.PermisoXPerfil;
import dp1.titandevelop.titano.persistent.Usuario;
import dp1.titandevelop.titano.view.CambiarPassword;
import dp1.titandevelop.titano.view.LoginT;
import dp1.titandevelop.titano.view.prod.ModulosT_PRO_ProcProdNuevo;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;

public class ModulosT_ADM extends javax.swing.JFrame {

    public static ModulosT_ADM_TEmp menuTEmp = null;
    public static ModulosT_ADM_Parametros menuParametro = null;
    public static ModulosT_ADM_AE menuEmp = null;
    public static ModulosT_ADM_AEEdit ventanaEdita = null;
    public static ModulosT_ADM_AENuevo ventanaNuevo = null;
    //public static ModulosT_ADM_TEmp menuTEmp = null;
    private BufferedImage imgFondo;

    /**
     * Creates new form ModulosTSEG
     */
    public ModulosT_ADM() {
        initComponents();
        this.setLocationRelativeTo(null);
        this.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        try {
            //this.getClass().getResource("/img/fondo.png").toURI();
            this.imgFondo = ImageIO.read(getClass().getResourceAsStream("/img/fondoTitanBright.png"));
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        escritorioADM = new javax.swing.JDesktopPane() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(imgFondo, 0, 0, this);
            }

            @Override
            public Dimension getPreferredSize() {
                return new Dimension(imgFondo.getWidth(), imgFondo.getHeight());
            }

        };
        jPanel3 = new javax.swing.JPanel();
        lblUsuario1 = new javax.swing.JLabel();
        lblUsuarioLogeado1 = new javax.swing.JLabel();
        lblCorreo1 = new javax.swing.JLabel();
        lblCorreoLogeado1 = new javax.swing.JLabel();
        btnCambiarPW1 = new javax.swing.JButton();
        lblPerfil1 = new javax.swing.JLabel();
        lblPerfilLogeado1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        menuParam = new javax.swing.JMenuItem();
        menuTipoEmp = new javax.swing.JMenuItem();
        menuEm = new javax.swing.JMenuItem();

        setTitle("Módulo de Administración");

        escritorioADM.setPreferredSize(new java.awt.Dimension(500, 600));

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        lblUsuario1.setText("Usuario:");

        lblUsuarioLogeado1.setText(LoginT.empleadoLogin.getNombres()+" "+LoginT.empleadoLogin.getApellidop()+" "+LoginT.empleadoLogin.getApellidom()+" "+"("+LoginT.userLogin.getUsuario()+")");

        lblCorreo1.setText("Correo:");

        lblCorreoLogeado1.setText(LoginT.empleadoLogin.getEmail());

        btnCambiarPW1.setText("Cambiar Password");
        btnCambiarPW1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        btnCambiarPW1.setPreferredSize(new java.awt.Dimension(121, 20));
        btnCambiarPW1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCambiarPW1ActionPerformed(evt);
            }
        });

        lblPerfil1.setText("Perfil:");

        lblPerfilLogeado1.setText(LoginT.perfilLogin.getDescripcion());

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/usuario.png"))); // NOI18N

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/perfilesactivos.png"))); // NOI18N

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/correo.png"))); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblUsuario1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblUsuarioLogeado1)
                .addGap(27, 27, 27)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblCorreo1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblCorreoLogeado1)
                .addGap(32, 32, 32)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblPerfil1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblPerfilLogeado1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
                .addComponent(btnCambiarPW1, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblUsuario1)
                    .addComponent(lblUsuarioLogeado1)
                    .addComponent(lblCorreo1)
                    .addComponent(lblCorreoLogeado1)
                    .addComponent(btnCambiarPW1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPerfil1)
                    .addComponent(lblPerfilLogeado1)
                    .addComponent(jLabel3)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)))
        );

        jMenu1.setText("Administrar");

        menuParam.setText("Parametros");
        menuParam.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuParamActionPerformed(evt);
            }
        });
        jMenu1.add(menuParam);

        menuTipoEmp.setText("Tipo Empleado");
        menuTipoEmp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuTipoEmpActionPerformed(evt);
            }
        });
        jMenu1.add(menuTipoEmp);

        menuEm.setText("Empleados");
        menuEm.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuEmActionPerformed(evt);
            }
        });
        jMenu1.add(menuEm);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(escritorioADM, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(escritorioADM, javax.swing.GroupLayout.DEFAULT_SIZE, 601, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuEmActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuEmActionPerformed

        //ID 57  Administrar Empleados
        //NO MODIFICAR !!!!!!!!!
        Integer i = 0;
        for (; i < LoginT.permisosxperfil.size(); i++) {
            if (57 == (Integer) LoginT.idspermisosxperfil.get(i)) {
                this.menuEmp = new ModulosT_ADM_AE();

                this.escritorioADM.add(menuEmp);
                Dimension desktopSize = this.getSize();
                Dimension jInternalFrameSize = menuEmp.getSize();
                menuEmp.setLocation((desktopSize.width - jInternalFrameSize.width) / 2,
                        (desktopSize.height - jInternalFrameSize.height) / 4);
                menuEmp.show();
                break;
            }
        }
        if (i >= LoginT.permisosxperfil.size()) {
            JOptionPane.showMessageDialog(this.escritorioADM, "No puedes proceder, al parecer careces de permisos.",
                    "No posee permisos",
                    JOptionPane.WARNING_MESSAGE);
        }




    }//GEN-LAST:event_menuEmActionPerformed

    private void menuTipoEmpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuTipoEmpActionPerformed
        //ID 56  Administrar Tipo Empleado
        //NO MODIFICAR !!!!!!!!!
        Integer i = 0;
        for (; i < LoginT.permisosxperfil.size(); i++) {
            if (56 == (Integer) LoginT.idspermisosxperfil.get(i)) {
                menuTEmp = new ModulosT_ADM_TEmp();
                this.escritorioADM.add(menuTEmp);
                Dimension desktopSize = this.getSize();
                Dimension jInternalFrameSize = menuTEmp.getSize();
                menuTEmp.setLocation((desktopSize.width - jInternalFrameSize.width) / 2,
                        (desktopSize.height - jInternalFrameSize.height) / 4);
                menuTEmp.show();
                break;
            }
        }
        if (i >= LoginT.permisosxperfil.size()) {
            JOptionPane.showMessageDialog(this.escritorioADM, "No puedes proceder, al parecer careces de permisos.",
                    "No posee permisos",
                    JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_menuTipoEmpActionPerformed

    private void menuParamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuParamActionPerformed
        menuParametro = new ModulosT_ADM_Parametros();
        this.escritorioADM.add(menuParametro);
        Dimension desktopSize = this.getSize();
        Dimension jInternalFrameSize = menuParametro.getSize();
        menuParametro.setLocation((desktopSize.width - jInternalFrameSize.width) / 2,
                (desktopSize.height - jInternalFrameSize.height) / 4);
        menuParametro.show();
    }//GEN-LAST:event_menuParamActionPerformed

    private void btnCambiarPW1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCambiarPW1ActionPerformed

        CambiarPassword chngpw = new CambiarPassword(new javax.swing.JFrame(), true);
        chngpw.setLocationRelativeTo(null);
        chngpw.setVisible(true);
    }//GEN-LAST:event_btnCambiarPW1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ModulosT_ADM.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ModulosT_ADM.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ModulosT_ADM.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ModulosT_ADM.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ModulosT_ADM().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCambiarPW1;
    private javax.swing.JDesktopPane escritorioADM;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JLabel lblCorreo1;
    private javax.swing.JLabel lblCorreoLogeado1;
    private javax.swing.JLabel lblPerfil1;
    private javax.swing.JLabel lblPerfilLogeado1;
    private javax.swing.JLabel lblUsuario1;
    private javax.swing.JLabel lblUsuarioLogeado1;
    private javax.swing.JMenuItem menuEm;
    private javax.swing.JMenuItem menuParam;
    private javax.swing.JMenuItem menuTipoEmp;
    // End of variables declaration//GEN-END:variables
}
